package com.kinon.markett2.fragment;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshGridView;
import com.kinon.markett2.Constants;
import com.kinon.markett2.MyApplication;
import com.kinon.markett2.R;
import com.kinon.markett2.adapter.DingdanAdapter;
import com.kinon.markett2.adapter.DingdandetialAdapter;
import com.kinon.markett2.bluetoothprint.BluetoothPrintFormatUtil;
import com.kinon.markett2.bluetoothprint.BluetoothService;
import com.kinon.markett2.bluetoothprint.DeviceListActivity;
import com.kinon.markett2.entity.DingdanEntity;
import com.kinon.markett2.entity.GoodSelBean;
import com.kinon.markett2.entity.OrderdetialEntity;
import com.kinon.markett2.sqlbean.BuyGoodsBean;
import com.kinon.markett2.sqlbean.UserBuyBean;
import com.kinon.markett2.tools.HttpTools;
import com.kinon.markett2.tools.NetWorkUtil;
import com.kinon.markett2.tools.SysTimeManage;
import com.loopj.android.http.JsonHttpResponseHandler;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.litepal.crud.DataSupport;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;

import static com.kinon.markett2.Constants.REQUEST_CONNECT_DEVICE;

/**
 * @author：郑谦
 * @时间：2017-3-28 下午5:38:13
 * @类名：DingdanFragment.java
 * @功能: 订单记录
 */
public class DingdanFragment extends Fragment {
    // Member object for the services
    public static BluetoothService mService = null;
    View iscatview = null;
    PullToRefreshGridView pull_dingdan;
    String token;
    DingdanAdapter dingdanAdapter;
    ArrayList<OrderdetialEntity> dingdandetiallist;
    DingdandetialAdapter dingdandetialAdapter;
    HttpTools toolModel = null;
    BluetoothPrintFormatUtil printFormatUtil = null;
    LinkedHashMap<String, LinkedList<String>> menuMsgMap;
    LinkedList<String> gonds;
    /**
     * 没有订单
     */
    private TextView tv_none;
    private int offset = 0;
    private int page = 20;
    /**
     * 商品信息的集合
     */
    private ArrayList<DingdanEntity> dingdanlist;
    // Name of the connected device
    private String mConnectedDeviceName = null;
    // String buffer for outgoing messages
    private StringBuffer mOutStringBuffer;
    // Local Bluetooth adapter
    private BluetoothAdapter mBluetoothAdapter = null;
    /**
     * 取餐编号
     */
    private String orderno;
    /**
     * 下单时间
     */
    private String order_time;
    /**
     * 商品总金额
     */
    private String total;
    /**
     * 姓名
     */
    private String name;
    /**
     * 电话
     */
    private String phone;
    /**
     * 总件数
     */
    private String totalamount;

    /**
     * 紧急情况下的数据
     */
    private ArrayList<UserBuyBean> userBuyList;

    private Context mContext;
    private final Handler mHandler = new Handler() {
        @SuppressLint("HandlerLeak")
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case Constants.MESSAGE_STATE_CHANGE:
                    switch (msg.arg1) {
                        case BluetoothService.STATE_CONNECTED:
                            break;
                        case BluetoothService.STATE_CONNECTING:
                            break;
                        case BluetoothService.STATE_LISTEN:
                        case BluetoothService.STATE_NONE:
//                	print_connect_btn.setText("无连接");
                            break;
                    }
                    break;
                case Constants.MESSAGE_WRITE:
                    break;
                case Constants.MESSAGE_READ:
                    break;
                case Constants.MESSAGE_DEVICE_NAME:
//					mConnectedDeviceName = msg.getData().getString(Constants.DEVICE_NAME);
//					Toast.makeText(getActivity(), "连接至"
//							+ mConnectedDeviceName, Toast.LENGTH_SHORT).show();
                    Toast.makeText(mContext, "蓝牙已连接",
                            Toast.LENGTH_SHORT).show();
                    break;
                case Constants.MESSAGE_TOAST:
                    Toast.makeText(mContext, msg.getData().getString(Constants.TOAST),
                            Toast.LENGTH_SHORT).show();
                    break;
            }
        }
    };
    private String orderid;
    /**
     * 商品详情弹窗
     */
    private OnItemClickListener itemclicke = new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int position,
                                long id) {
            if (!Constants.URGENT_TYPE) {
                Detialdialog(dingdanlist.get(position).getId(), position);
            } else {
                Detialdialog("", position);
            }
        }
    };
    /**
     * 上下拉刷新
     */
    private PullToRefreshBase.OnRefreshListener2<GridView> onrefresh = new PullToRefreshBase.OnRefreshListener2<GridView>() {
        @Override
        public void onPullDownToRefresh(PullToRefreshBase<GridView> refreshView) {
            offset = 0;
            dingdanlist.clear();
            toolModel.getOrders(token, page + "", offset + "", new JsonDingdans());
            if (NetWorkUtil.isNetwork(mContext) == false) {
                Toast.makeText(mContext, "当前网络不可用", Toast.LENGTH_SHORT).show();
                pull_dingdan.onRefreshComplete();
                return;
            }
        }

        @Override
        public void onPullUpToRefresh(PullToRefreshBase<GridView> refreshView) {
            offset += page;
            toolModel.getOrders(token, page + "", offset + "",
                    new JsonDingdans());
            if (NetWorkUtil.isNetwork(mContext) == false) {
                Toast.makeText(mContext, "当前网络不可用", Toast.LENGTH_SHORT).show();
                pull_dingdan.onRefreshComplete();
                return;
            }
        }
    };

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mContext = activity;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_dingdan, null);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initRes();
    }

    private void initRes() {
        SharedPreferences sp = mContext.getSharedPreferences("spReg",
                Context.MODE_PRIVATE);
        token = sp.getString("data", "");
        pull_dingdan = (PullToRefreshGridView) getView().findViewById(
                R.id.pull_dingdan);


        pull_dingdan.setOnItemClickListener(itemclicke);
        tv_none = (TextView) getView().findViewById(R.id.tv_none);

        //判断是否是紧急情况
        if (!Constants.URGENT_TYPE) {
            pull_dingdan.setMode(PullToRefreshBase.Mode.BOTH);
            pull_dingdan.setOnRefreshListener(onrefresh);
            getDingdaninfo();
        } else {
            getBuyInfo();
        }

        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        // If the adapter is null, then Bluetooth is not supported
        if (mBluetoothAdapter == null) {
            Toast.makeText(mContext, "您的设备不支持蓝牙", Toast.LENGTH_SHORT).show();
            return;
        }
        if (!mBluetoothAdapter.isEnabled()) {
            //打开蓝牙
            Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableIntent, Constants.REQUEST_ENABLE_BT);
        }
        if (mService == null) {
            mService = new BluetoothService(mContext, mHandler);
        }
    }

    /**
     * 紧急情况下运行的代码
     */
    private void getBuyInfo() {
        long sysTime = System.currentTimeMillis();
        String date = SysTimeManage.getInstage().getDate(sysTime);
        userBuyList = (ArrayList<UserBuyBean>)
                DataSupport.where("date=?", date).find(UserBuyBean.class, true);
                        /*.order("orderno desc")*/

        DingdanAdapter adapter = new DingdanAdapter(mContext, userBuyList, 0);
        pull_dingdan.setAdapter(adapter);
    }

    /**
     * 获取订单列表
     */
    private void getDingdaninfo() {
        if (NetWorkUtil.isNetwork(mContext) == false) {
            Toast.makeText(mContext, "当前网络不可用", Toast.LENGTH_SHORT).show();
            return;
        }
        dingdanlist = new ArrayList<DingdanEntity>();

        toolModel = new HttpTools(getActivity());
        toolModel.getOrders(token, page + "", offset + "",
                new JsonDingdans());
    }

    private void urgentPrint(int position, TextView tv_orderno, TextView tv_time,
                             TextView tv_fukuanren, TextView tv_heji,
                             ListView lv) {
//		gonds=new LinkedList<>();
        ArrayList<BuyGoodsBean> buyList = userBuyList.get(position).getDetails();
        if (buyList == null || buyList.size() == 0) {
            Toast.makeText(mContext, "获取数据失败", Toast.LENGTH_SHORT).show();
            return;
        }
        int amount = 0;
        for (BuyGoodsBean i : buyList) {
            gonds.add(" \n" + i.getName());
            gonds.add("*" + i.getAmount() + "");
            gonds.add("" + i.getPrice() + "");
            dingdandetiallist.add(new OrderdetialEntity
                    (i.getName() + "", i.getAmount() + "", i.getPrice() + ""));
            amount += i.getAmount();
        }
        totalamount = amount + "";

        tv_orderno.setText(userBuyList.get(position).getOrderno());
        tv_time.setText(userBuyList.get(position).getTime());
        tv_heji.setText("￥" + userBuyList.get(position).getTotal());
        tv_fukuanren.setText(userBuyList.get(position).getCard());
        dingdandetialAdapter = new DingdandetialAdapter(mContext, dingdandetiallist);
        lv.setAdapter(dingdandetialAdapter);
        lv.setDivider(null);
    }

    /**
     * 商品详情
     */
    private void Detialdialog(final String id, final int position) {
        final Dialog dialog = new Dialog(getActivity());
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setCanceledOnTouchOutside(false);
        iscatview = LayoutInflater.from(getActivity()).inflate(
                R.layout.dialog_orderdetial, null);
        final TextView tv_orderno = (TextView) iscatview.findViewById(R.id.tv_bianhao);
        final TextView tv_time = (TextView) iscatview.findViewById(R.id.tv_time);
        final TextView tv_fukuanren = (TextView) iscatview.findViewById(R.id.tv_fukuanren);
        final TextView tv_heji = (TextView) iscatview.findViewById(R.id.tv_heji);
        final ListView lv = (ListView) iscatview.findViewById(R.id.lv_shangpin);
        Button btn_wancheng = (Button) iscatview.findViewById(R.id.btn_wancheng);
        Button btn_daying = (Button) iscatview.findViewById(R.id.btn_dddaying);
        Button btn_refund = (Button) iscatview.findViewById(R.id.btn_refund);

        dialog.setContentView(iscatview);
        dialog.show();

        btn_daying.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mService.getState() != BluetoothService.STATE_CONNECTED) {
                    Toast.makeText(mContext, "蓝牙没有连接", Toast.LENGTH_SHORT).show();
                    Intent serverIntent = new Intent(mContext, DeviceListActivity.class);
                    startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
                    return;
                } else {
                    if (!Constants.URGENT_TYPE) {
                        if (MyApplication.subModel.equals("T1mini")) {
                            miniPrint(totalamount, total, orderno, order_time, name, phone);
                        } else {
                            print(totalamount, total, orderno, order_time, name, phone);
                        }
                    } else {
                        if (MyApplication.subModel.equals("T1mini")) {
                            miniPrint(totalamount, userBuyList.get(position).getTotal() + "",
                                    userBuyList.get(position).getOrderno(),
                                    userBuyList.get(position).getTime(),
                                    userBuyList.get(position).getCard(), "");
                        } else {
                            print(totalamount, userBuyList.get(position).getTotal() + "",
                                    userBuyList.get(position).getOrderno(),
                                    userBuyList.get(position).getTime(),
                                    userBuyList.get(position).getCard(), "");
                        }
                    }
                    dialog.dismiss();
                }
            }
        });
        btn_wancheng.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        btn_refund.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                List<GoodSelBean> goods = new ArrayList<GoodSelBean>();
                for (int i = 0; i < dingdandetiallist.size(); i++) {
                    //判断是否被选中
                    boolean isChecked = lv.isItemChecked(i);
                    if (isChecked) {
                        goods.add(new GoodSelBean(dingdandetiallist.get(i).getGoods_id(),
                                dingdandetiallist.get(i).getAmount()));
                    }
                }
                if (null == goods || goods.size() == 0) {
                    Toast.makeText(mContext, "请点击选择退款的商品", Toast.LENGTH_SHORT).show();
                    return;
                }
                Gson gson = new Gson();
                refund(dialog, orderid,
                        gson.toJson(goods));
            }
        });
        //商品的点击事件
        lv.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                dingdandetialAdapter.notifyDataSetChanged();
            }
        });

        dingdandetiallist = new ArrayList<OrderdetialEntity>();
        menuMsgMap = new LinkedHashMap<String, LinkedList<String>>();
        gonds = new LinkedList<String>();

        if (!Constants.URGENT_TYPE) {
            lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
            dingdandetialAdapter = new DingdandetialAdapter(lv, mContext, dingdandetiallist);
            lv.setAdapter(dingdandetialAdapter);
            lv.setDivider(null);

            getPrintInfo(id, tv_orderno, tv_time, tv_fukuanren, tv_heji, lv);
        } else {
            btn_refund.setVisibility(View.GONE);
            urgentPrint(position, tv_orderno, tv_time, tv_fukuanren, tv_heji, lv);
        }

    }
//	public void updateSeletedCount(ListView listView){
//		mSelectedCount.setText(Integer.toString(listView.getCheckedItemCount()));
//	}

    private void refund(final Dialog dialog, String id, String object) {
        if (toolModel == null) {
            toolModel = new HttpTools(getActivity());
        }
        toolModel.refund(token, id, object, new JsonHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                super.onSuccess(statusCode, headers, response);
                try {
                    if (response.getBoolean("code")) {
                        Toast.makeText(mContext, "退款成功", Toast.LENGTH_SHORT).show();
                        dialog.dismiss();
                        orderid = "";
                    } else {
                        Toast.makeText(mContext, response.getString("msg"),
                                Toast.LENGTH_SHORT).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }

            @Override
            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                super.onFailure(statusCode, headers, responseString, throwable);
                Log.e("lh", "refund==" + responseString);
                Toast.makeText(mContext, "退款失败", Toast.LENGTH_SHORT).show();
            }
        });
//		toolModel
    }


    private void getPrintInfo(String id, final TextView tv_orderno, final TextView tv_time,
                              final TextView tv_fukuanren, final TextView tv_heji,
                              final ListView lv) {
        if (toolModel == null) {
            toolModel = new HttpTools(getActivity());
        }
        toolModel.getOrderdetial(token, id,
                new JsonHttpResponseHandler() {
                    @Override
                    public void onSuccess(int statusCode, Header[] headers,
                                          JSONObject response) {
                        super.onSuccess(statusCode, headers, response);
                        try {
                            boolean code = response.getBoolean("code");
                            String msg = response.getString("msg");
//							Log.e("lh","订单详情----"+response.toString());
                            if (code == true) {
                                JSONObject object = response.getJSONObject("data");
                                String username = object.getString("user");
                                String num = object.getString("num");
                                JSONObject data = object.getJSONObject("wsbill");
                                orderid = data.getString("id");
                                String ref = data.getString("ref");
                                String time = data.getString("biz_dt");
                                name = object.getString("user");
                                phone = object.getString("phone");
                                totalamount = object.getString("count");
                                total = object.getString("num");
//						JSONObject data = object.getJSONObject("wsbill");
                                orderno = data.getString("ref");
                                order_time = data.getString("biz_dt");
                                JSONArray array = object.getJSONArray("goods");
                                for (int i = 0; i < array.length(); i++) {
                                    JSONObject goods = array.getJSONObject(i);
                                    String name = goods.getString("name");
                                    String goods_count = goods.getString("goods_count");
                                    String price = goods.getString("inventory_money");
                                    String goods_id = goods.getString("goods_id");
                                    gonds.add(" \n" + name);
                                    gonds.add("*" + goods_count);
                                    gonds.add("" + price);
                                    dingdandetiallist.add(new OrderdetialEntity(name, goods_count, price, goods_id));
                                }
                                tv_orderno.setText(ref);
                                tv_time.setText(time);
                                tv_heji.setText("￥" + num);
                                tv_fukuanren.setText(username);

                                dingdandetialAdapter.notifyDataSetChanged();
                            } else {
                                Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
                            }
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }

                });
    }

    private void print(String totalamount, String total, String orderno, String order_time,
                       String name, String phone) {
        sendMessage(printFormatUtil.printTitle("                 智慧食堂") + "\n");
        sendMessage(printFormatUtil.printTitle("************************************************") + "\n");
        sendMessage("名称" + "               " + "数量" + "                 " + "价格" + " \n");
        menuMsgMap.put("", gonds);
        sendMessage(printFormatUtil.printMenuMSG(menuMsgMap));
        sendMessage("数量：" + totalamount + "份" + "   ");
        sendMessage("总价：" + total + "元" + " \n");
        sendMessage("订单编号：" + orderno + " \n");
        sendMessage("下单时间：" + order_time + " \n");
        if (!Constants.URGENT_TYPE) {
            sendMessage("姓名：" + name + " \n");
            sendMessage("联系电话：" + phone + " \n");
        } else {
            sendMessage("卡号：" + name + " \n");
        }

        sendMessage(printFormatUtil.printTitle("***********************************************") + "\n");
        sendMessage(printFormatUtil.printTitle("             请妥善保管好购物凭证" + "\n"));
        sendMessage(printFormatUtil.printTitle("                 谢谢惠顾！") + "\n");
        sendMessage(" \n");
        sendMessage(" \n");
        sendMessage(" \n");
        sendMessage(" \n");
        sendMessage(" \n");
    }

    private void miniPrint(String totalamount, String total, String orderno, String order_time,
                           String name, String phone) {
        sendMessage(printFormatUtil.printTitle("    智慧食堂") + "\n");
        sendMessage(printFormatUtil.printTitle("********************************") + "\n");
        sendMessage("名称" + "         " + "数量" + "           " + "价格" + " \n");
        menuMsgMap.put("", gonds);
        sendMessage(printFormatUtil.printMenuMSG(menuMsgMap));
        sendMessage("数量：" + totalamount + "份" + "   ");
        sendMessage("总价：" + total + "元" + " \n");
        sendMessage("订单编号：" + orderno + " \n");
        sendMessage("下单时间：" + order_time + " \n");
        if (!Constants.URGENT_TYPE) {
            sendMessage("姓名：" + name + " \n");
            sendMessage("联系电话：" + phone + " \n");
        } else {
            sendMessage("卡号：" + name + " \n");
        }

        sendMessage(printFormatUtil.printTitle("********************************") + "\n");
        sendMessage(printFormatUtil.printTitle("       请妥善保管好购物凭证" + "\n"));
        sendMessage(printFormatUtil.printTitle("          谢谢惠顾！") + "\n");
        sendMessage(" \n");
        sendMessage(" \n");
        sendMessage(" \n");
        sendMessage(" \n");
        sendMessage(" \n");
    }

    /**
     * 打印
     *
     * @param message
     */
    private void sendMessage(String message) {
        if (message.length() > 0) {
            // Get the message bytes and tell the BluetoothService to write
            byte[] send;
            try {
                send = message.getBytes("GB2312");
            } catch (UnsupportedEncodingException e) {
                send = message.getBytes();
            }

            mService.write(send);
        }
    }


    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
            case Constants.REQUEST_CONNECT_DEVICE:
                if (resultCode == Activity.RESULT_OK) {
                    String address = data.getExtras()
                            .getString(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
                    BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
                    mService.connect(device);
                }
                break;
            case Constants.REQUEST_ENABLE_BT:
                // When the request to enable Bluetooth returns
                if (resultCode == Activity.RESULT_OK) {
//                setupChat();
                    Toast.makeText(mContext, "蓝牙已打开", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(mContext, "蓝牙没有打开", Toast.LENGTH_SHORT).show();
//                finish();
                }
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.scan:
                Intent serverIntent = new Intent(mContext, DeviceListActivity.class);
                startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
                return true;
            case R.id.disconnect:
                mService.stop();
                return true;
        }
        return false;
    }

    private class JsonDingdans extends JsonHttpResponseHandler {
        @Override
        public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
            super.onSuccess(statusCode, headers, response);
            try {
                boolean code = response.getBoolean("code");
                String msg = response.getString("msg");
                if (code == true) {
                    JSONArray data = response.getJSONArray("data");
                    for (int i = 0; i < data.length(); i++) {
                        JSONObject object = data.getJSONObject(i);
                        String id = object.getString("id");
                        String user = object.getString("user");
                        String time = object.getString("biz_dt");
                        dingdanlist.add(new DingdanEntity(id, user, time));
                    }
                    View vLine = getView().findViewById(R.id.vLine);
                    if (dingdanlist.size() == 0) {
                        tv_none.setVisibility(View.VISIBLE);
                        vLine.setVisibility(View.GONE);
                    } else {
                        tv_none.setVisibility(View.GONE);
                    }
                    dingdanAdapter = new DingdanAdapter(mContext, dingdanlist);
                    pull_dingdan.setAdapter(dingdanAdapter);
                    pull_dingdan.getRefreshableView().setSelection(offset);
                    pull_dingdan.setDividerDrawable(null);
                    //				Utility.setGridViewHeightBasedOnChildren(pull_twosort);
                    pull_dingdan.onRefreshComplete();
                } else {
//					pull_dingdan.onRefreshComplete();
                    Toast.makeText(mContext, msg, Toast.LENGTH_SHORT).show();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
            super.onFailure(statusCode, headers, responseString, throwable);
            Log.w("WZY", "onFailure: " + responseString, throwable);
            Toast.makeText(mContext, "网络请求超时", Toast.LENGTH_SHORT).show();
        }

    }
}
